#include "InputManager.h"

InputManager* InputManager::inputMgr = NULL;

InputManager::InputManager()
{
	m_Handlers.reserve(20);
}

InputManager::~InputManager()
{
}

InputManager* InputManager::getSingleton()
{
	if(inputMgr == NULL)
		inputMgr = new InputManager();

	return  inputMgr;
}

bool InputManager::checkIsInStore(string name)
{
	for(it = m_Handlers.begin(); it != m_Handlers.end(); ++it)
	{
		if( (*it)->getName() == name )
		{
			return true;
		}
	}
	return false;
}

void InputManager::ManageInputHandler(InputHandler *handler)
{
	if(!checkIsInStore(handler->getName()))
	{
		m_Handlers.push_back(handler);
	}
}

InputHandler* InputManager::getHandler(std::string name)
{
	for(it = m_Handlers.begin(); it != m_Handlers.end(); ++it)
	{
		if( (*it)->getName() == name )
		{
			return (*it);
		}
	}
	return NULL;
}
